<template>
    <!-- 标题区域 -->
    <van-nav-bar title="商品列表" left-text="返回" left-arrow @click-left="() => { $router.push('/home/cla') }" fixed />
    <div style="height: 45px;"></div>
    <!-- 渲染区域 卡片 -->
    <div v-for="item in goodsData">
        <router-link :to="'/detail/'+item.goods_id">
            <van-card  :price="item.goods_price"  :title="item.goods_name"  :thumb="item.goods_big_logo ? item.goods_big_logo :'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg' " />
        </router-link>
        
    </div>

</template>

<script setup>
// 引入ref
import { ref } from 'vue'
// 获取路由中传递的参数
import { useRoute } from 'vue-router'
const route = useRoute()
// console.log('路由参数',route.params.cat_name)
// 自定义 商品列表数据
let goodsData = ref([])
// 引入列表接口、
import { goodsApi } from '@/api/api'
goodsApi(route.params.cat_name).then(res => {
    console.log('商品列表', res)
    goodsData.value = res.data.message.goods
})
</script>

<style lang="scss" scoped></style>